S*** SHAKTI ANALYSIS: NIGHT LIGHTS
*** JU 2016-July-15

use "/home/jurpelai/Dropbox/Night Lights Validation (Eugenie, Ryan, Johannes)/Data/Shakti/Shakti_ANALYSIS.dta"
cd "/home/jurpelai/Dropbox/Night Lights Validation (Eugenie, Ryan, Johannes)"

clear all
cd "/home/emd/Dropbox/Night Lights Validation (Eugenie, Ryan, Johannes)"
use "./Data/Shakti/Shakti_ANALYSIS.dta"


*** VARIABLE MANIPULATION

replace v_q36_1_streetlight_number = 0 if v_q36_1_streetlight_number == .

*JU NOTE: REMOVE WHEN 100 ERROR CORRECTED
gen nonelectrified_hh_nbr_log = .
replace nonelectrified_hh_nbr_log = log((100 - electrified_hh_per)/100 * c11_2011_total_hhs + 1)

gen day_hrs = m2_q69 - m2_q70
replace day_hrs = 0 if day_hrs <0
rename m2_q70 night_hrs

*** COLLAPSE, ANALYZE

preserve

collapse SH_sum_11 power_households total_households v_q36_1_streetlight_number m1_q32_month_expenditure electrified_hh_nbr nonelectrified_hh_nbr_log day_hrs night_hrs, by(m1_q11_village_code)

*TEMP FIX
replace electrified_hh_nbr = electrified_hh_nbr/100

gen SH_sum_11_log = log(SH_sum_11 + 1)
gen electrified_hh_nbr_log = log(electrified_hh_nbr + 1)
gen log_exp = log(m1_q32_month_expenditure)
gen log_street = log(v_q36_1_streetlight_number+1)

gen day_sum_hrs = electrified_hh_nbr * day_hrs
gen night_sum_hrs = electrified_hh_nbr * night_hrs
gen log_day_sum_hrs = log(day_sum_hrs+1)
gen log_night_sum_hrs = log(night_sum_hrs+1)

*** LABELING

label variable SH_sum_11 "Night lights (shape, sum, 2011)"
label variable electrified_hh_nbr "Electrified HH (nbr)"
label variable nonelectrified_hh_nbr "Non-electrified HH (nbr)"
label variable m1_q32_month_expenditure "Average HH Expenditure (INR)"
label variable v_q36_1_streetlight_number "Street Lights (nbr)"
label variable day_sum_hrs "Day Electricity Hours * Electrified HH"
label variable night_sum_hrs "Night Electricity Hours * Electrified HH"

label variable SH_sum_11_log "Night lights (shape, log sum, 2011)"
label variable electrified_hh_nbr_log "Electrified HH (log nbr)"
label variable nonelectrified_hh_nbr_log "Non-electrified HH (log nbr)"
label variable log_exp "Average HH Expenditure (log INR)"
label variable log_street "Street Lights (log nbr)"
label variable log_day_sum_hrs "Day Electricity Hours * Electrified HH (log)"
label variable log_night_sum_hrs "Night Hours of Electricity * Electrified HH (log)"

label variable night_hrs "Night Hours of Electricity"

scatter electrified_hh_nbr SH_sum_11_log, graphregion(color(white)) bgcolor(white)
graph export ./Manuscript/Figures/scatter_access_main.png, replace

scatter log_street SH_sum_11_log, graphregion(color(white)) bgcolor(white)
graph export ./Manuscript/Figures/scatter_access_streetlights.png, replace


scatter night_sum_hrs SH_sum_11_log, graphregion(color(white)) bgcolor(white)
graph export ./Manuscript/Figures/scatter_access_hourshh.png, replace


scatter night_hrs SH_sum_11_log, graphregion(color(white)) bgcolor(white)
graph export ./Manuscript/Figures/scatter_access_hours.png, replace




*** SUMMARY STATISTICS

eststo clear
quietly estpost sum SH_sum_11_log electrified_hh_nbr m1_q32_month_expenditure v_q36_1_streetlight_number day_sum_hrs night_sum_hrs SH_sum_11_log electrified_hh_nbr_log log_exp log_street log_day_sum_hrs log_night_sum_hrs
esttab using "./Manuscript/Tables/shakti_summarystats.tex", replace nonum cells("count mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") noobs label booktabs


*** RESULTS: VERY NICE

eststo clear
eststo: reg SH_sum_11_log electrified_hh_nbr_log nonelectrified_hh_nbr_log
eststo: reg SH_sum_11_log log_street
eststo: reg SH_sum_11_log log_exp
eststo: reg SH_sum_11_log electrified_hh_nbr_log nonelectrified_hh_nbr_log log_street log_exp
eststo: reg SH_sum_11_log log_day_sum_hrs
eststo: reg SH_sum_11_log log_night_sum_hrs
eststo: reg SH_sum_11_log log_day_sum_hrs log_night_sum_hrs
esttab using "./Manuscript/Tables/shakti_results.tex", replace b(%9.3f) stats(r2 N, fmt(%9.3f %9.3g) label("R-squared" "Observations")) booktabs eqlabels(none) noconstant se label star(* 0.10 ** 0.05 *** 0.01) nomtitles addnote ("Dependent variable: Night lights (shape, log, sum, 2011).")
